package cn.com.cdb.ldms.base;

import lombok.Data;

@Data
public class Result<T> {
    private long timestamp = System.currentTimeMillis();
    private String code;
    private String msg;
    private T data;

    // 静态方法：快速构建失败响应
    public static <T> Result<T> fail(String code, String msg) {
        Result<T> result = new Result<>();
        result.setCode(code);
        result.setMsg(msg);
        return result;
    }

    public static <T> Result<T> success() {
        return success(null);
    }

    // 静态方法：快速构建失败响应
    public static <T> Result<T> success(T data) {
        Result<T> result = new Result<>();
        result.setCode("000000");
        result.setMsg("SUCCESS");
        result.setData(data);
        return result;
    }
}
